using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ITOMMS.Business;
using ITOMMS.Entity;
using System.Drawing;

namespace ITOMMS.Web.Main
{
    public partial class _default : BasePage
    {
        public string sublefmenu = string.Empty;
        public string headerMenu;
        public string sCompanyName = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                sublefmenu = MenuSetHelper.GetLeftSubMenuList();

                this.lblCurrentDate.Text = DateTime.Now.ToString("yyyy-MM-dd tt") + "  " + DateTime.Now.ToString("dddd", new System.Globalization.CultureInfo("zh-cn"));
                if (SessionHelper.UserEntity != null)
                {
                    this.lblUserID.Text = SessionHelper.UserEntity.UserName;
                    this.lblUserType.Text = System.Enum.GetName(typeof(Business.PubEnums.RoleGroup), SessionHelper.UserEntity.RoleGroup);
                    if (SessionHelper.UserEntity.LastLoginTime != null)
                    {
                        this.lblLastLoingTime.Text = SessionHelper.UserEntity.LastLoginTime.Value.ToString();
                    }
                    SessionHelper.UserEntity.LoginNum = SessionHelper.UserEntity.LoginNum + 1;
                    this.lblLoinCount.Text = SessionHelper.UserEntity.LoginNum.ToString();
                    SessionHelper.UserEntity.LastLoginTime = System.DateTime.Now;
                    //this.lblCompanyName.Text = SessionHelper.UserEntity.CompanyName;
                    sCompanyName = SessionHelper.UserEntity.CompanyName;

                    new tbUserEntity().Update(SessionHelper.UserEntity);
                }

            }

            headerMenu = Business.MenuSetHelper.GetHeadMenuList();
            //sublefmenu = Business.MenuSetHelper.GetLeftSubMenuList();
        }

        protected void butQuit_Click(object sender, ImageClickEventArgs e)
        {
            Session.Clear();
            HttpCookie cookie = Request.Cookies["COOIKE_AUTH_KEY"];
            if (cookie != null)
            {
                cookie.Expires = DateTime.Now.AddDays(-1);
                cookie.Values.Clear();
                System.Web.HttpContext.Current.Response.Cookies.Set(cookie);
            }
            Response.Redirect("~/login.aspx", true);

        }




    }
}
